package com.waitingresult.date;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.waitingresult.entity.User;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author: WangShuai
 * @CreateTime: 2022-11-25  09:36
 * @Description: TODO
 * @Version: 1.0
 */
public class LocalDateTimeDemo {
    static String LOGISTICS_POSTCODE_AREA_COST = "ABC:";
    static String logisticsMethodId = "20";
    static String concatTempId = "50";
    static  Integer num = -1;

    private static void extracted1() {
    //extracted();
//        LocalDateTime of = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
//        System.err.println(of);
    String redisKey = LOGISTICS_POSTCODE_AREA_COST + String.join(":", logisticsMethodId, concatTempId);
    String s = "ABCS" + String.join(":", num > 0 ? "0" : String.valueOf(30), String.valueOf(30));
    }
    public static void main(String[] args) throws Exception {
        //extracted1();
        ArrayList<User> list = new ArrayList<>();
        list.add(new User(1L, "张三", "安徽"));
        list.add(new User(2L, "李四", "上海"));
        list.add(new User(3L, "王五", "安徽"));
        List<User> address = list.stream().filter(x -> x.getAddress().equals("上海")).toList();
        address.forEach(System.out::println);
        BigDecimal percentage = BigDecimal.ZERO;
        System.err.println(percentage.compareTo(BigDecimal.ZERO) > 0);

    }


    private static void extracted() throws Exception {
        //        LocalDateTime now = LocalDateTime.now();
//        LocalDateTime of = LocalDateTimeUtil.of(new Date());
//        System.err.println(now);
//        System.err.println(of);


        // Date date = dateFormat("2022-12-30 10:59:31");
        DateTime parse = DateUtil.parse("2022-12-30 10:59:31");
        DateTime parse1 = DateUtil.parse("2022-12-30");
        Date date = dateFormat("2022-12-30");
        System.err.println(date);
        System.err.println("ok");
    }

    public static Date dateFormat(String dateString) throws Exception {
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
        Date result = null;
        try {
            result = sdf1.parse(dateString);
        } catch (ParseException e) {
            result = sdf2.parse(dateString);
        }
        return result;
    }
}
